﻿#region Copyright(C) 2018 FI Ltd. All rights reserved.
// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME	    : FI.Net Application Framework
// COMPONENT ID	    : FI.Core
// COMPONENT DESC   : FI.Net Core Foundation
//
// CREATED DATE/BY  : 18 Aug 2018 / Tian Mi
//
// REVISION HISTORY :	
// DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================
#endregion

using FI.Core.Utilities;

namespace FI.Core
{
    /// <summary>
    /// This class defines some extension methods against <see cref="StatefulEntry"/>.
    /// </summary>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Stateful")]
    public static class StatefulEntryExtensions
    {
        /// <summary>
        /// Marks as the specified state.
        /// </summary>
        /// <param name="entry">The stateful entry.</param>
        /// <param name="state">The target state.</param>
        public static void MarkAs(this StatefulEntry entry, EntryState state)
        {
            Guard.ArgumentNotNull(entry, "entry");
            entry.State = state;
        }

        /// <summary>
        /// Marks the added.
        /// </summary>
        /// <param name="entry">The entry.</param>
        public static void MarkAdded(this StatefulEntry entry)
        {
            entry.MarkAs(EntryState.Added);
        }

        /// <summary>
        /// Marks as deleted.
        /// </summary>
        /// <param name="entry">The entry.</param>
        public static void MarkAsDeleted(this StatefulEntry entry)
        {
            entry.MarkAs(EntryState.Deleted);
        }

        /// <summary>
        /// Marks as modified.
        /// </summary>
        /// <param name="entry">The entry.</param>
        public static void MarkAsModified(this StatefulEntry entry)
        {
            entry.MarkAs(EntryState.Modified);
        }

        /// <summary>
        /// Marks as unchanged.
        /// </summary>
        /// <param name="entry">The entry.</param>
        public static void MarkAsUnchanged(this StatefulEntry entry)
        {
            entry.MarkAs(EntryState.Unchanged);
        }
    }
}
